---
hide_table_of_contents: true
---

import CodeBlock from "@theme/CodeBlock";

# Weaviate

Weaviate is an open source vector database that stores both objects and vectors, allowing for combining vector search with structured filtering.
LangChain connects to Weaviate via the `weaviate-ts-client` package, the official Typescript client for Weaviate.

LangChain inserts vectors directly to Weaviate, and queries Weaviate for the nearest neighbors of a given vector, so that you can use all the LangChain Embeddings integrations with Weaviate.

## Setup

Weaviate has their own standalone integration package with LangChain, accessible via [`@langchain/weaviate`](https://www.npmjs.com/package/@langchain/weaviate) on NPM!

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/weaviate @langchain/openai @langchain/community
```

You'll need to run Weaviate either locally or on a server, see [the Weaviate documentation](https://weaviate.io/developers/weaviate/installation) for more information.

## Usage, insert documents

import InsertExample from "@examples/indexes/vector_stores/weaviate_fromTexts.ts";

<CodeBlock language="typescript">{InsertExample}</CodeBlock>

## Usage, query documents

import QueryExample from "@examples/indexes/vector_stores/weaviate_search.ts";

<CodeBlock language="typescript">{QueryExample}</CodeBlock>

## Usage, maximal marginal relevance

import MaximumMarginalRelevanceExample from "@examples/indexes/vector_stores/weaviate_mmr.ts";

You can use maximal marginal relevance search, which optimizes for similarity to the query AND diversity.

<CodeBlock language="typescript">{MaximumMarginalRelevanceExample}</CodeBlock>

## Usage, delete documents

import DeleteExample from "@examples/indexes/vector_stores/weaviate_delete.ts";

<CodeBlock language="typescript">{DeleteExample}</CodeBlock>
